//不要给我WA WA 叫
//一定AC
//author:Return.
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iomanip>
#include <climits>
#define int long long 
#define x first 
#define y second 
using namespace std;

const int N = 55; 
int n, m;
char a[N][N];
bool visited[N][N]; 
bool found = false; 
int sx, sy, ex, ey;

bool check(int x, int y) {
    return (x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] == a[sx][sy]);//a[sx][sy] = '#'
    }

void dfs(int x, int y) {
    if ((x == ex - 1 && y == ey) || (x == ex + 1 && y == ey) || 
        (x == ex && y == ey - 1) || (x == ex && y == ey + 1))
    {
        found = true;
        return;
    }

    visited[x][y] = true;

    if (check(x + 1, y) && !visited[x + 1][y]) dfs(x + 1, y);
    if (check(x, y + 1) && !visited[x][y + 1]) dfs(x, y + 1);
    if (check(x, y - 1) && !visited[x][y - 1]) dfs(x, y - 1);
    if (check(x - 1, y) && !visited[x - 1][y]) dfs(x - 1, y);

}

void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++) 
    {
        for (int j = 1; j <= m; j++) 
        {
            cin >> a[i][j];
        }
    }

    cin >> sx >> sy >> ex >> ey;

    memset(visited, 0, sizeof(visited));

    dfs(sx, sy);

    if (found) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    while(t -- ) solve();
    return 0;
}
